<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="月份" prop="month" label-width="120">
        <el-date-picker clearable
                        v-model="queryParams.month"
                        type="month"
                        value-format="yyyyMM"
                        placeholder="请选择月份">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-plus"
              size="mini"
              @click="handleExport"
              v-hasPermi="['system:user:add']"
            >导出</el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>

        <el-table v-loading="loading" :data="dataList" :show-summary="true">
          <el-table-column label="街道" align="center"  prop="deptName">
            <template slot-scope="scope">
              <el-link type="primary" @click="handleDetail(scope.row)">{{scope.row.deptName}}</el-link>
            </template>
          </el-table-column>
          <el-table-column label="应完成（次）" align="center" prop="totalCount"  />
          <el-table-column label="已完成（次）" align="center" prop="finishCount"  />
          <el-table-column label="未开始（次）" align="center" prop="unbeginCount"  />
          <el-table-column label="进行中（次）" align="center" prop="runCount"  />
<!--          <el-table-column label="已超期（次）" align="center" prop="expireCount"  />-->
        </el-table>
  </div>
</template>

<script>
import { listRegionServeReportData } from "@/api/report/report";

export default {
  name: "RegionServeReport",
  dicts: ['serve_task_status'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 查询参数
      queryParams: {
        month: undefined,
      },
      // 显示搜索条件
      showSearch: true,
      dataList:[]
    };
  },
  created() {
    this.getList();
    //默认选中当前月
    var nowDate = new Date();
    var date = {
      year: nowDate.getFullYear(),
      month: nowDate.getMonth() + 1
    };
    const dayDate = date.year + (date.month >= 10 ? date.month : "0" + date.month);
    this.queryParams.month = dayDate.toString();

  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      listRegionServeReportData(this.queryParams).then(response => {
          this.loading = false;
          this.dataList = response.data;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('report/exportRegionServeReport', {
        ...this.queryParams
      }, `区域服务统计报表_${new Date().getTime()}.xlsx`)
    },
    handleDetail(row){
      //需要传的数据
      //路由跳转到新页面
      this.$router.push({  //核心语句
        path:'/report/serviceLog',  //跳转的路径
        query:{             //路由传参时push和query搭配使用 ，作用时传递参数
          deptId:row.deptId,
          month:this.queryParams.month
        }

      })

    },
  }
};
</script>
